% $Id: DistanceAnalyzer.m 2 2008-11-04 12:49:37Z Jie.Bao $

classdef DistanceAnalyzer
%DISTANCEANALYZER does statistics on the distance traveled in a list of
%points
%   2 functions. Constructor which takes x,y,z lists of points. and
%   GetLength() which simply calculates the total distance traveled.

   properties
       X;
       Y;
       Z;
       Distances
   end

   methods
       %CONSTRUCTOR
       %inputs x,y,z coordinates. Calculates distances for every
       %consecutive points
       function obj = DistanceAnalyzer(x,y,z)
           obj.X = x;
           obj.Y = y;
           if nargin == 3
               obj.Z = z;
           else
               obj.Z = zeros(length(x), 1);  % 2-D coordinates
           end
           
           for i=1:length(x)-1
               obj.Distances(i) = distance(obj.X(i), obj.X(i+1), ...
                   obj.Y(i), obj.Y(i+1), obj.Z(i), obj.Z(i+1));
           end
       end
       
       
       %MAIN FUCNTIONS
       
       %calculates the sum of distances between points.
       function total = GetLength(obj)
           total = sum(obj.Distances);
       end
       

   end
end 
